﻿using System;
namespace Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000 {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="auditList", Namespace="http://producers.ehma-10000000.xtee.riik.ee/producer/ehma-10000000", Target=typeof(AuditList))]
    public class AuditListSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IAuditList clazz;
        
        public AuditListSerializer(IAuditList clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            for (int x = 0; ((clazz.Audit != null) 
                        && (x < clazz.Audit.Count)); x = (x + 1)) {
                if (clazz.Audit[x]!=null) {
                    Writer.WriteStartElement("audit");
                    global::Xtee.Core.SerializationMetadata metaAudit = this.GetMetaData(clazz.Audit[x]);
                    Writer.WriteTypeAttribute(metaAudit.TypeQualifiedName.Namespace, metaAudit.TypeQualifiedName.Name);
                    metaAudit.NewSerializer(clazz.Audit[x]).WriteXml(Writer);
                    Writer.WriteEndElement();
                }
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="audit") {
                clazz.Audit = new System.Collections.Generic.List<global::Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000.IAudit>();
                for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                            && (Reader.LocalName == "audit")); ) {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>auditList>audit");
                    }
                    global::Xtee.Core.SerializationMetadata metaAudit = this.GetMetaData<global::Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000.IAudit>(Reader, "audit", "http://producers.ehma-10000000.xtee.riik.ee/producer/ehma-10000000");
                    global::Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000.IAudit item = metaAudit.NewEntity<global::Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000.IAudit>();
                    clazz.Audit.Add(item);
                    if ((Reader.IsEmptyElement == false)) {
                        Reader.ReadStartElement("audit");
                        metaAudit.NewSerializer(item).ReadXml(Reader);
                        Reader.ReadEndElement();
                    }
                    else {
                        Reader.Skip();
                    }
                }
            }
        }
    }
}
